/*
 * /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//package MuleGame;
package MuleGUI;
import java.awt.*;

import java.beans.*;
import java.util.ArrayList;

import javax.swing.*;
import javax.swing.event.*;

import MuleBackend.Game;
import MuleBackend.GameDriver;
import MuleBackend.Land;
import MuleBackend.Player;
import MuleBackend.Stages.TimeClass;
import MuleBackend.Town;
//import MuleGUI.StagesGUI.Progress;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JLabel;
import javax.swing.LayoutStyle.ComponentPlacement;

/**
 * 
* This class contains methods and variables necessary for initializing
* and instantiating a graphical user interface that is displayed whenever
* a Land or good is auctioned. It will also hold information pertinent to
* player-interactive features associated with land and good auction, such
* as action listeners and parameters involved in system.in input. 
*/

public class GoodAuctionGUI extends javax.swing.JFrame {
	//Timer variables
	TimeClass tc = new TimeClass();	
	Timer timer = new Timer(1000, tc);
	static int timeAssigned = 32;
	//auction variables
	ArrayList<Player> buyingPlayers;
	ArrayList<Player> sellingPlayers;
	Town town;
	Player lowSellingPlayer;
	Player highBuyingPlayer;
	int lowestSellPrice;
	int highestBid;
	int phase;
	static int goodType=0;
	
	//KeyListener
	KeyAuction listener;
	
   /**
    * Initializes a new GUI.
    */
   public GoodAuctionGUI() {
       initComponents();
   }
   
   public void setLabel(String title) {
		this.setTitle(title);
		auctionLabel.setText(title);
	}
   
   /**
    *  Initializes offer labels
    * 
    *
    */
   private void setValues(){
	   //Sets max and minimum price for land
	   town = GameDriver.game.getTown();
	   town.setPrices();
	   maxMoney.setText("$" + String.valueOf(town.getMaxPrice(goodType)));
	   minMoney.setText("$"+String.valueOf(town.getMinPrice(goodType)));
	   ArrayList<Player> players = GameDriver.game.getPlayerList();
	   JLabel[] offerLabels = new JLabel[4];
	   offerLabels[0]=player1Offer;
	   offerLabels[1]=player2Offer;
	   offerLabels[2]=player3Offer;
	   offerLabels[3]=player4Offer;
	   for(int k=0;k<4;k++){
		   offerLabels[k].setText("");
	   }
	   for(int k=0;k<players.size();k++){
		  // offerLabels[k].setLocation(offerLabels[k].getLocationOnScreen().x,offerLabels[k].getLocationOnScreen().y+500);
		   offerLabels[k].setText("$0");
	   }
	   
	   //Sets up player location
	   int y = buyLabel.getLocation().y;
	   for(int k=0;k<players.size();k++){
		   int i = Player.returnIndexByID(players,k+1);
		   players.get(i).setXY(offerLabels[k].getLocation().x,y);
	   }

   }
   
   /**
    * Sets things up for good Auction phase
    * 
    */
   public void startGoodAuction(){
	   //winner = null;
	   //this.landForSale = landForSale;
	   setValues();
	   listener = new KeyAuction();
	   addKeyListener(listener);
	   //repaint();
	   tc.setCounter(timeAssigned);
	   timer.start();
   }
   
   public void paint(Graphics g){
		super.paint(g);
		ArrayList<Player> players = GameDriver.game.getPlayerList();
		int xCordStart = jSeparator1.getLocation().x;
		int xCordEnd = storeAuctionLabel.getLocation().x;
		if(highBuyingPlayer!=null)
			g.drawLine(xCordStart, highBuyingPlayer.getXY().y, xCordEnd, highBuyingPlayer.getXY().y);
		if(lowSellingPlayer!=null)
			g.drawLine(xCordStart, lowSellingPlayer.getXY().y, xCordEnd, lowSellingPlayer.getXY().y);
		   
		for(int k=0;k<players.size();k++){
			Player currentPlayer = players.get(k);
			if(buyingPlayers.contains(currentPlayer))
				g.drawImage(currentPlayer.getRace().getImage(),currentPlayer.getXY().x, currentPlayer.getXY().y, 50, 50,null);
			else
				g.drawImage(currentPlayer.getRace().getImage(),currentPlayer.getXY().x, currentPlayer.getXY().y-50, 50, 50,null);
			//offerLabels[k].setBounds(currentPlayer.getXY().x,currentPlayer.getXY().y+100,currentPlayer.getName().length()*5,18);
		}
	}
   
   public void removeListener(){
	   removeKeyListener(listener);
   }
   
   /**
	 * KeyAuction class in charge of responding to users offering bids for land auction
	 * Player 1: q- higher bid, a- lower bid
	 * Player 2: e- higher bid, d- lower bid
	 * Player 3: t- higher bid, g- lower bid
	 * Player 4: u- higher bid, j- lower bid
	 * 
	 */
	public class KeyAuction implements KeyListener {
		ArrayList<Player> players;
		int maxPrice, leastPrice;
		int[] goodUnits;
		int[] bids;
		int[] sellPrices;
		int lenPlayers;
		int highBuyerInt, lowSellerInt;
		int speed;	
		int speedChange;
		/**
		 * Initializes components
		 * 
		 * @param land land for sale
		 */
		public KeyAuction(){
			maxPrice = town.getMaxPrice(goodType);
			leastPrice = town.getMinPrice(goodType);
			highBuyerInt = -1;
			lowSellerInt = -1;
			highBuyingPlayer = null;
			lowSellingPlayer = null;
			phase = 1;
			players = GameDriver.game.getPlayerList();
			buyingPlayers = new ArrayList<>();
			for(int k=0;k<players.size();k++)
				buyingPlayers.add(players.get(k));
			sellingPlayers = new ArrayList<>();
			lenPlayers = buyingPlayers.size();
			//lenSellers = 0;
			//lenBuyers = lenPlayers;
			goodUnits = new int[lenPlayers];
			bids = new int[lenPlayers]; //max buying players size
			sellPrices = new int[lenPlayers]; // max selling players size
			lowestSellPrice = maxPrice;
			for(int k=0;k<lenPlayers;k++)
				sellPrices[k]=lowestSellPrice-1;
			updateSpeedChange();
			maxPrice = GameDriver.game.getTown().getMaxPrice(goodType);
			leastPrice = GameDriver.game.getTown().getMinPrice(goodType);
		}
		
		private void updateSpeedChange(){
			double yCordDifference= minLabel.getLocation().y - maxLabel.getLocation().y;
			double amountDifference = (maxPrice - leastPrice);
			double speedDifference = yCordDifference/amountDifference;
			speedChange = (int)speedDifference;
			//System.out.println("SPEED = " + speedChange);
		}
		@Override
		public void keyTyped(KeyEvent e) {
			char ch = e.getKeyChar(); // character inputed
			int x=-1;//selecting player, start at -1
			Player currentPlayer=null;
			if(ch=='q' && lenPlayers>=1 || ch=='e' && lenPlayers>=2 || ch=='t' && lenPlayers>=3 || ch=='u' && lenPlayers>=4){
				if(ch=='q') x= Player.returnIndexByID(players, 1);
				if(ch=='e') x= Player.returnIndexByID(players, 2);
				if(ch=='t') x= Player.returnIndexByID(players, 3);
				if(ch=='u') x= Player.returnIndexByID(players, 4);
				currentPlayer = players.get(x);
				if(phase==1){
					if(sellingPlayers.contains(currentPlayer)==false){
					//Adds player to list of selling players if he has sufficient assets
						int units = currentPlayer.unitsToSell(goodType);
						if(units>0){
							goodUnits[x]=units;
							sellingPlayers.add(currentPlayer);
							buyingPlayers.remove(currentPlayer);
							currentPlayer.setXY(currentPlayer.getXY().x, maxMoney.getLocation().y);
						}
					}
				}
				
				if(phase==2){
					if(buyingPlayers.contains(currentPlayer)){
						if(currentPlayer.hasMoney(leastPrice+1)){
							if(bids[x]==0){
								bids[x]=leastPrice+1;
								speed = - (buyLabel.getLocation().y - minLabel.getLocation().y) - speedChange;
							}
							else
							if(bids[x]!=lowestSellPrice && currentPlayer.hasMoney(bids[x]+1)){
								bids[x]+=1;
								speed = -speedChange;
							}
						}
						if(bids[x]>highestBid){
							if(Progress.getTime() < 25){
								Progress.addTime();
								tc.setCounter(timeAssigned/4);
							}
							highestBid=bids[x];
							highBuyerInt = x;
							highBuyingPlayer = players.get(highBuyerInt);
						}
					}
					else
					if(sellingPlayers.contains(currentPlayer)){
						if(sellPrices[x]!=maxPrice-1){
							sellPrices[x]+=1;
							speed = -speedChange;
						}
						Boolean sameSeller = true;
						if(lowSellerInt==x){
							for(int k=0;k<lenPlayers;k++){
								if(sellPrices[k]<sellPrices[x]){
									sameSeller = false;
									lowSellerInt=k;
									lowSellingPlayer = players.get(lowSellerInt);
								}
							}
							if(sameSeller == true){
								if(sellPrices[x]==maxPrice-1){
									lowestSellPrice = maxPrice-1;
									//If the lowest seller backs down, the next lowest seller is the losing player with the lowest price
									lowSellingPlayer = sellingPlayers.get(0);
								}
								else{
									lowestSellPrice+=1;
								}
							}
						}
						
					}
				}
			}
			if(ch=='a' && lenPlayers>=1 || ch=='d' && lenPlayers>=2 || ch=='g' && lenPlayers>=3 || ch=='j' && lenPlayers>=4){
				if(ch=='a') x= Player.returnIndexByID(players, 1);
				if(ch=='d') x= Player.returnIndexByID(players, 2);
				if(ch=='g') x= Player.returnIndexByID(players, 3);
				if(ch=='j') x= Player.returnIndexByID(players, 4);
				currentPlayer = players.get(x);
				if(phase==1){
					if(buyingPlayers.contains(currentPlayer)==false){
						buyingPlayers.add(currentPlayer);
						sellingPlayers.remove(currentPlayer);
						currentPlayer.setXY(currentPlayer.getXY().x, buyLabel.getLocation().y);
					}
				}
				if(phase==2){
					if(buyingPlayers.contains(currentPlayer)){
						if(bids[x]==leastPrice+1){
							bids[x]=0;
							speed = (buyLabel.getLocation().y - minLabel.getLocation().y) + speedChange;
						}
						else
						if(bids[x]==0);
						else{
							bids[x]-=1;
							speed = speedChange;
						}
						
						Boolean sameBuyer = true;
						if(highBuyerInt==x){
							for(int k=0;k<lenPlayers;k++){
								if(bids[k]>bids[x]){
									sameBuyer = false;
									highBuyerInt=k;
									highBuyingPlayer = players.get(highBuyerInt);
								}
							}
							if(sameBuyer == true){
								if(bids[x]==0){
									highestBid = 0;
									highBuyingPlayer = null;
								}
								else
									highestBid-=1;
							}
						}
					}
					if(sellingPlayers.contains(currentPlayer)){
						if(sellPrices[x]>highestBid && sellPrices[x]!=leastPrice){
							sellPrices[x]-=1;
							speed = speedChange;
						}
						if(sellPrices[x] < lowestSellPrice){
							if(Progress.getTime() < 25){
								Progress.addTime();
								tc.setCounter(timeAssigned/4);
							}
							lowestSellPrice = sellPrices[x];
							lowSellerInt = x;
							lowSellingPlayer = players.get(x);
						}
					}
				}
			}
			
			if(ch=='b'){
				//System.out.println("Hit");
				if(highBuyingPlayer!=null && lowSellingPlayer!=null){
					//System.out.println("Players not null");
					if(highestBid == lowestSellPrice){
						//System.out.println("High bid = low sell");
						System.out.println("Transaction took place");
						highBuyingPlayer.addGood(goodType);
						lowSellingPlayer.deductGood(goodType);
						highBuyingPlayer.deductMoney(highestBid);
						lowSellingPlayer.addMoney(highestBid);
						goodUnits[lowSellerInt]--;
						if(highBuyingPlayer.hasMoney(highestBid)==false){
							x = highBuyerInt;
							currentPlayer = highBuyingPlayer;
							bids[highBuyerInt] = 0;
							highBuyingPlayer.setXY(lowSellingPlayer.getXY().x, buyLabel.getLocation().y);
							highBuyingPlayer = null;
							highestBid = 0;
							for(int k=0;k<players.size();k++)
								if(bids[k]>bids[highBuyerInt]){
									highBuyingPlayer = players.get(k);
									highBuyerInt = Player.returnIndexByID(players,highBuyingPlayer.getPlayerID());
									highestBid = bids[k];
								}
							if(highBuyingPlayer==null)
								tc.setCounter(1);
						}
						if(goodUnits[lowSellerInt]==0){
							int labelID = lowSellingPlayer.getPlayerID()-1;
							if(labelID==0)player1Offer.setText("");
							if(labelID==1)player2Offer.setText("");
							if(labelID==2)player3Offer.setText("");
							if(labelID==3)player4Offer.setText("");
							sellingPlayers.remove(lowSellingPlayer);
							if(sellingPlayers.isEmpty() || buyingPlayers.isEmpty()){
								tc.setCounter(1);
							}
							sellPrices[lowSellerInt] = maxPrice;
							lowestSellPrice = maxPrice;
							lowSellingPlayer.setXY(lowSellingPlayer.getXY().x, buyLabel.getLocation().y);
							lowSellingPlayer = null;
							for(int k=0;k<players.size();k++)
								if(sellPrices[k]<sellPrices[lowSellerInt]){
									lowSellingPlayer = players.get(k);
									lowSellerInt = Player.returnIndexByID(players,lowSellingPlayer.getPlayerID());
									lowestSellPrice = sellPrices[k];
								}
							repaint();

						}
					}
				}
				
				else
				if(highBuyingPlayer!=null){
					if(highestBid == maxPrice){
						System.out.println("Transaction took place");
						highBuyingPlayer.addGood(goodType);
						town.deductGood(goodType);
						highBuyingPlayer.deductMoney(maxPrice);
						if(town.hasGood(goodType)==false)
							tc.setCounter(1);
						if(highBuyingPlayer.hasMoney(maxPrice)==false){
							int labelID = highBuyingPlayer.getPlayerID()-1;
							if(labelID==0)player1Offer.setText("");
							if(labelID==1)player2Offer.setText("");
							if(labelID==2)player3Offer.setText("");
							if(labelID==3)player4Offer.setText("");
							highBuyingPlayer.setXY(highBuyingPlayer.getXY().x, buyLabel.getLocation().y);
							buyingPlayers.remove(highBuyingPlayer);
							bids[highBuyerInt] = 0;
							highestBid = 0;
							highBuyingPlayer = null;
							for(int k=0;k<players.size();k++)
								if(bids[k]>bids[highBuyerInt]){
									highBuyingPlayer = players.get(k);
									highBuyerInt = Player.returnIndexByID(players,highBuyingPlayer.getPlayerID());
									highestBid = bids[k];
								}
							if(highBuyingPlayer==null)
								tc.setCounter(1);
							repaint();
						}
						
					}
				}
				else
				if(lowSellingPlayer!=null){
					if(lowestSellPrice == leastPrice){
						System.out.println("Transaction took place");
						town.addGood(goodType);
						lowSellingPlayer.deductGood(goodType);
						lowSellingPlayer.addMoney(leastPrice);
						goodUnits[lowSellerInt]--;
						if(goodUnits[lowSellerInt]==0){
							int labelID = lowSellingPlayer.getPlayerID()-1;
							if(labelID==0)player1Offer.setText("");
							if(labelID==1)player2Offer.setText("");
							if(labelID==2)player3Offer.setText("");
							if(labelID==3)player4Offer.setText("");
							sellingPlayers.remove(lowSellingPlayer);
							if(sellingPlayers.isEmpty()){
								tc.setCounter(1);
							}
							sellPrices[lowSellerInt] = maxPrice;
							lowestSellPrice = maxPrice;
							lowSellingPlayer.setXY(lowSellingPlayer.getXY().x, buyLabel.getLocation().y);
							lowSellingPlayer = null;
							for(int k=0;k<players.size();k++)
								if(sellPrices[k]<sellPrices[lowSellerInt]){
									lowSellingPlayer = players.get(k);
									lowSellerInt = Player.returnIndexByID(players,lowSellingPlayer.getPlayerID());
									lowestSellPrice = sellPrices[k];
								}
							if(lowSellingPlayer == null)
								tc.setCounter(1);
							repaint();

						}
					}
				}
				
			}
			//If some change was made
			if(x!=-1){
				int labelID = currentPlayer.getPlayerID()-1;
				Point cord = currentPlayer.getXY();
				currentPlayer.setXY(cord.x,cord.y+speed);
				if(buyingPlayers.contains(currentPlayer)){
					if(labelID==0)player1Offer.setText("$"+Integer.toString(bids[x]));
					if(labelID==1)player2Offer.setText("$"+Integer.toString(bids[x]));
					if(labelID==2)player3Offer.setText("$"+Integer.toString(bids[x]));
					if(labelID==3)player4Offer.setText("$"+Integer.toString(bids[x]));
				}
				else
				if(sellingPlayers.contains(currentPlayer)){
					if(labelID==0)player1Offer.setText("$"+Integer.toString(sellPrices[x]));
					if(labelID==1)player2Offer.setText("$"+Integer.toString(sellPrices[x]));
					if(labelID==2)player3Offer.setText("$"+Integer.toString(sellPrices[x]));
					if(labelID==3)player4Offer.setText("$"+Integer.toString(sellPrices[x]));
				}
				repaint();
			}
			speed=0;
			
		}

		@Override
		public void keyPressed(KeyEvent e) {
			// TODO Auto-generated method stub
			
		}

		@Override
		public void keyReleased(KeyEvent e) {
			// TODO Auto-generated method stub
			
		}
	}
	
	public class TimeClass implements ActionListener {
		int counter;

		/**
		 * constructor for the TimeClass
		 * @param count the length of time for the timer?
		 */
		public TimeClass() {
			counter = 0;
		}
		public void setCounter(int counter){
			this.counter=counter;
		}

		/**
		 * action to perform when timer hits 0
		 * increments the auction stage for the next good type
		 * kills progress bar
		 * calls on next stage
		 * 
		 */
		public void actionPerformed(ActionEvent tc) {
			counter--;
			if(counter== (3*timeAssigned/4)){
				phase=2;
				if(sellingPlayers.isEmpty() && town.hasGood(goodType)==false){
					counter = 1;
				}
			}
			if (counter == 0) {
				Progress.killBar();
				goodType++;
				goodType = goodType%4;
				removeListener();
				GameDriver.game.getStages().startStage(GameDriver.game.getStages().getCurrentStage() + 1);
			}
			
		}
	}
	
	public static class Progress implements Runnable{
		static int loopTimer;
		public static void addTime(){
			loopTimer = 25;
		}
		public static int getTime(){
			return loopTimer;
		}
		public static void killBar(){
			loopTimer = 1;
		}
		public void run() {
			for(loopTimer=100;loopTimer>=0;loopTimer--){
				jProgressBar1.setValue(loopTimer);
				jProgressBar1.repaint();
				
				try{
					Thread.sleep(timeAssigned*10);
				}catch(Exception ex){}
			}
		}
	}
	
	public void jProgressBar(){
		new Thread(new Progress()).start();
	}
	

   /**
    * This method is called from within the constructor to initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is always
    * regenerated by the Form Editor.
    */
   @SuppressWarnings("unchecked")
   // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
   private void initComponents() {
	  
// Instantiation of labels and panels:

       player4StatusPanel = new javax.swing.JLayeredPane();
       player4NameLabel = new javax.swing.JLabel();
       player4MoneyLabel = new javax.swing.JLabel();
       player4FoodLabel = new javax.swing.JLabel();
       player4EnergyLabel = new javax.swing.JLabel();
       player4SmithoreLabel = new javax.swing.JLabel();
       player4Name = new javax.swing.JLabel();
       player4Money = new javax.swing.JLabel();
       player4Food = new javax.swing.JLabel();
       player4Energy = new javax.swing.JLabel();
       player4Smithore = new javax.swing.JLabel();
       player2StatusPanel = new javax.swing.JLayeredPane();
       player2NameLabel = new javax.swing.JLabel();
       player2MoneyLabel = new javax.swing.JLabel();
       player2FoodLabel = new javax.swing.JLabel();
       player2EnergyLabel = new javax.swing.JLabel();
       player2SmithoreLabel = new javax.swing.JLabel();
       player2Name = new javax.swing.JLabel();
       player2Money = new javax.swing.JLabel();
       player2Food = new javax.swing.JLabel();
       player2Energy = new javax.swing.JLabel();
       player2Smithore = new javax.swing.JLabel();
       storeStatusPanel = new javax.swing.JLayeredPane();
       storeLabel = new javax.swing.JLabel();
       storeFoodLabel = new javax.swing.JLabel();
       storeEnergyLabel = new javax.swing.JLabel();
       storeSmithoreLabel = new javax.swing.JLabel();
       storeMuleLabel = new javax.swing.JLabel();
       storeAmount = new javax.swing.JLabel();
       storeFood = new javax.swing.JLabel();
       storeEnergy = new javax.swing.JLabel();
       storeSmithore = new javax.swing.JLabel();
       storeMule = new javax.swing.JLabel();
       player1StatusPanel = new javax.swing.JLayeredPane();
       player1NameLabel = new javax.swing.JLabel();
       player1MoneyLabel = new javax.swing.JLabel();
       player1FoodLabel = new javax.swing.JLabel();
       player1EnergyLabel = new javax.swing.JLabel();
       player1SmithoreLabel = new javax.swing.JLabel();
       player1Name = new javax.swing.JLabel();
       player1Money = new javax.swing.JLabel();
       player1Food = new javax.swing.JLabel();
       player1Energy = new javax.swing.JLabel();
       player1Smithore = new javax.swing.JLabel();
       player3StatusPanel = new javax.swing.JLayeredPane();
       player3NameLabel = new javax.swing.JLabel();
       player3MoneyLabel = new javax.swing.JLabel();
       player3FoodLabel = new javax.swing.JLabel();
       player3EnergyLabel = new javax.swing.JLabel();
       player3SmithoreLabel = new javax.swing.JLabel();
       player3Name = new javax.swing.JLabel();
       player3Money = new javax.swing.JLabel();
       player3Food = new javax.swing.JLabel();
       player3Energy = new javax.swing.JLabel();
       player3Smithore = new javax.swing.JLabel();
       jProgressBar1 = new javax.swing.JProgressBar();
       jProgressBar1.setStringPainted(true);
       jProgressBar1.setOrientation(SwingConstants.VERTICAL);
       jSeparator1 = new javax.swing.JSeparator();
       buyLabel = new javax.swing.JLabel();
       sellLabel = new javax.swing.JLabel();
       minLabel = new javax.swing.JLabel();
       maxLabel = new javax.swing.JLabel();
       maxMoney = new javax.swing.JLabel();
       minMoney = new javax.swing.JLabel();
       storeAuctionLabel = new javax.swing.JLabel();
       auctionLabel = new javax.swing.JLabel();
       player1Bid = new javax.swing.JLabel();
       player2Bid = new javax.swing.JLabel();
       player3Bid = new javax.swing.JLabel();
       player4Bid = new javax.swing.JLabel();

//Configuring the GUI panel components and text fields:
       
       setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
       setTitle("Land Auction (land auction GUI)");
       setResizable(false);
       
       player1StatusPanel.setBackground(new java.awt.Color(102, 102, 0));
       player1StatusPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51)));
       player1StatusPanel.setForeground(new java.awt.Color(51, 51, 51));
       
       player1NameLabel.setText("Player:");
       player1NameLabel.setBounds(10, 10, 40, 20);
       player1StatusPanel.add(player1NameLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player1MoneyLabel.setText("Money:");
       player1MoneyLabel.setBounds(10, 30, 40, 14);
       player1StatusPanel.add(player1MoneyLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player1FoodLabel.setText("Food:");
       player1FoodLabel.setBounds(10, 50, 34, 14);
       player1StatusPanel.add(player1FoodLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player1EnergyLabel.setText("Energy:");
       player1EnergyLabel.setBounds(10, 70, 50, 14);
       player1StatusPanel.add(player1EnergyLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player1SmithoreLabel.setText("Smithore:");
       player1SmithoreLabel.setBounds(10, 90, 50, 14);
       player1StatusPanel.add(player1SmithoreLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player1Name.setText("....");
       player1Name.setBounds(60, 10, 40, 20);
       player1StatusPanel.add(player1Name, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player1Money.setText("....");
       player1Money.setBounds(60, 30, 40, 14);
       player1StatusPanel.add(player1Money, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player1Food.setText("....");
       player1Food.setBounds(60, 50, 34, 14);
       player1StatusPanel.add(player1Food, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player1Energy.setText("....");
       player1Energy.setBounds(60, 70, 50, 14);
       player1StatusPanel.add(player1Energy, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player1Smithore.setText("....");
       player1Smithore.setBounds(60, 90, 50, 14);
       player1StatusPanel.add(player1Smithore, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player2StatusPanel.setBackground(new java.awt.Color(102, 102, 0));
       player2StatusPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51)));
       player2StatusPanel.setForeground(new java.awt.Color(51, 51, 51));

       player2NameLabel.setText("Player:");
       player2NameLabel.setBounds(10, 10, 40, 20);
       player2StatusPanel.add(player2NameLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player2MoneyLabel.setText("Money:");
       player2MoneyLabel.setBounds(10, 30, 40, 14);
       player2StatusPanel.add(player2MoneyLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player2FoodLabel.setText("Food:");
       player2FoodLabel.setBounds(10, 50, 34, 14);
       player2StatusPanel.add(player2FoodLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player2EnergyLabel.setText("Energy:");
       player2EnergyLabel.setBounds(10, 70, 50, 14);
       player2StatusPanel.add(player2EnergyLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player2SmithoreLabel.setText("Smithore:");
       player2SmithoreLabel.setBounds(10, 90, 50, 14);
       player2StatusPanel.add(player2SmithoreLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player2Name.setText("....");
       player2Name.setBounds(60, 10, 40, 20);
       player2StatusPanel.add(player2Name, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player2Money.setText("....");
       player2Money.setBounds(60, 30, 40, 14);
       player2StatusPanel.add(player2Money, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player2Food.setText("....");
       player2Food.setBounds(60, 50, 34, 14);
       player2StatusPanel.add(player2Food, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player2Energy.setText("....");
       player2Energy.setBounds(60, 70, 50, 14);
       player2StatusPanel.add(player2Energy, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player2Smithore.setText("....");
       player2Smithore.setBounds(60, 90, 50, 14);
       player2StatusPanel.add(player2Smithore, javax.swing.JLayeredPane.DEFAULT_LAYER);
       
       player3StatusPanel.setBackground(new java.awt.Color(102, 102, 0));
       player3StatusPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51)));
       player3StatusPanel.setForeground(new java.awt.Color(51, 51, 51));

       player3NameLabel.setText("Player:");
       player3NameLabel.setBounds(10, 10, 40, 20);
       player3StatusPanel.add(player3NameLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player3MoneyLabel.setText("Money:");
       player3MoneyLabel.setBounds(10, 30, 40, 14);
       player3StatusPanel.add(player3MoneyLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player3FoodLabel.setText("Food:");
       player3FoodLabel.setBounds(10, 50, 34, 14);
       player3StatusPanel.add(player3FoodLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player3EnergyLabel.setText("Energy:");
       player3EnergyLabel.setBounds(10, 70, 50, 14);
       player3StatusPanel.add(player3EnergyLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player3SmithoreLabel.setText("Smithore:");
       player3SmithoreLabel.setBounds(10, 90, 50, 14);
       player3StatusPanel.add(player3SmithoreLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player3Name.setText("....");
       player3Name.setBounds(60, 10, 40, 20);
       player3StatusPanel.add(player3Name, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player3Money.setText("....");
       player3Money.setBounds(60, 30, 40, 14);
       player3StatusPanel.add(player3Money, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player3Food.setText("....");
       player3Food.setBounds(60, 50, 34, 14);
       player3StatusPanel.add(player3Food, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player3Energy.setText("....");
       player3Energy.setBounds(60, 70, 50, 14);
       player3StatusPanel.add(player3Energy, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player3Smithore.setText("....");
       player3Smithore.setBounds(60, 90, 50, 14);
       player3StatusPanel.add(player3Smithore, javax.swing.JLayeredPane.DEFAULT_LAYER);
       
       player4StatusPanel.setBackground(new java.awt.Color(102, 102, 0));
       player4StatusPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51), new java.awt.Color(51, 51, 51)));
       player4StatusPanel.setForeground(new java.awt.Color(51, 51, 51));

       player4NameLabel.setText("Player:");
       player4NameLabel.setBounds(10, 10, 40, 20);
       player4StatusPanel.add(player4NameLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player4MoneyLabel.setText("Money:");
       player4MoneyLabel.setBounds(10, 30, 40, 14);
       player4StatusPanel.add(player4MoneyLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player4FoodLabel.setText("Food:");
       player4FoodLabel.setBounds(10, 50, 34, 14);
       player4StatusPanel.add(player4FoodLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player4EnergyLabel.setText("Energy:");
       player4EnergyLabel.setBounds(10, 70, 50, 14);
       player4StatusPanel.add(player4EnergyLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player4SmithoreLabel.setText("Smithore:");
       player4SmithoreLabel.setBounds(10, 90, 50, 14);
       player4StatusPanel.add(player4SmithoreLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player4Name.setText("....");
       player4Name.setBounds(60, 10, 40, 20);
       player4StatusPanel.add(player4Name, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player4Money.setText("....");
       player4Money.setBounds(60, 30, 40, 14);
       player4StatusPanel.add(player4Money, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player4Food.setText("....");
       player4Food.setBounds(60, 50, 34, 14);
       player4StatusPanel.add(player4Food, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player4Energy.setText("....");
       player4Energy.setBounds(60, 70, 50, 14);
       player4StatusPanel.add(player4Energy, javax.swing.JLayeredPane.DEFAULT_LAYER);

       player4Smithore.setText("....");
       player4Smithore.setBounds(60, 90, 50, 14);
       player4StatusPanel.add(player4Smithore, javax.swing.JLayeredPane.DEFAULT_LAYER);
      
       storeStatusPanel.setBackground(new java.awt.Color(0, 0, 0));
       storeStatusPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(0, 0, 0), new java.awt.Color(0, 0, 0), new java.awt.Color(0, 0, 0), new java.awt.Color(0, 0, 0)));

       storeLabel.setText("Store:");
       storeLabel.setBounds(10, 10, 40, 20);
       storeStatusPanel.add(storeLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       storeFoodLabel.setText("Food:");
       storeFoodLabel.setBounds(10, 30, 40, 14);
       storeStatusPanel.add(storeFoodLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       storeEnergyLabel.setText("Energy:");
       storeEnergyLabel.setBounds(10, 50, 40, 14);
       storeStatusPanel.add(storeEnergyLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       storeSmithoreLabel.setText("Smithore:");
       storeSmithoreLabel.setBounds(10, 70, 50, 14);
       storeStatusPanel.add(storeSmithoreLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       storeMuleLabel.setText("Mule:");
       storeMuleLabel.setBounds(10, 90, 50, 14);
       storeStatusPanel.add(storeMuleLabel, javax.swing.JLayeredPane.DEFAULT_LAYER);

       storeAmount.setText("....");
       storeAmount.setBounds(60, 10, 40, 20);
       storeStatusPanel.add(storeAmount, javax.swing.JLayeredPane.DEFAULT_LAYER);

       storeFood.setText("....");
       storeFood.setBounds(60, 30, 40, 14);
       storeStatusPanel.add(storeFood, javax.swing.JLayeredPane.DEFAULT_LAYER);

       storeEnergy.setText("....");
       storeEnergy.setBounds(60, 50, 34, 14);
       storeStatusPanel.add(storeEnergy, javax.swing.JLayeredPane.DEFAULT_LAYER);

       storeSmithore.setText("....");
       storeSmithore.setBounds(60, 70, 50, 14);
       storeStatusPanel.add(storeSmithore, javax.swing.JLayeredPane.DEFAULT_LAYER);

       storeMule.setText("....");
       storeMule.setBounds(60, 90, 50, 14);
       storeStatusPanel.add(storeMule, javax.swing.JLayeredPane.DEFAULT_LAYER);

       

       jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

       buyLabel.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
       buyLabel.setText("Buy");

       sellLabel.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
       sellLabel.setText("Sell");

       minLabel.setText("Min");

       maxLabel.setText("Max");

       maxMoney.setText("$...");

       minMoney.setText("$...");

       storeAuctionLabel.setText("Store");

       auctionLabel.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
       auctionLabel.setText("Land Auction");

       player1Bid.setText("Player 1 Bid");

       player2Bid.setText("Player 2 Bid");

       player3Bid.setText("Player 4 Bid");

       player4Bid.setText("Player 3 Bid");
       
       player1Offer = new JLabel("New label");
       
       player2Offer = new JLabel("New label");
       
       player3Offer = new JLabel("New label");
       
       player4Offer = new JLabel("New label");

       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
       layout.setHorizontalGroup(
       	layout.createParallelGroup(Alignment.LEADING)
       		.addGroup(layout.createSequentialGroup()
       			.addComponent(player1StatusPanel, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE)
       			.addPreferredGap(ComponentPlacement.RELATED)
       			.addComponent(player2StatusPanel, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE)
       			.addPreferredGap(ComponentPlacement.RELATED)
       			.addComponent(player3StatusPanel, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE)
       			.addPreferredGap(ComponentPlacement.RELATED)
       			.addComponent(player4StatusPanel, GroupLayout.PREFERRED_SIZE, 139, GroupLayout.PREFERRED_SIZE)
       			.addPreferredGap(ComponentPlacement.RELATED)
       			.addComponent(storeStatusPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
       		.addGroup(layout.createSequentialGroup()
       			.addGap(39)
       			.addGroup(layout.createParallelGroup(Alignment.TRAILING)
       				.addGroup(layout.createSequentialGroup()
       					.addComponent(sellLabel)
       					.addGap(32)
       					.addComponent(maxLabel))
       				.addComponent(minLabel)
       				.addComponent(maxMoney)
       				.addGroup(layout.createSequentialGroup()
       					.addComponent(buyLabel)
       					.addGap(52))
       				.addComponent(minMoney))
       			.addGap(18)
       			.addComponent(jSeparator1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
       			.addGap(51)
       			.addGroup(layout.createParallelGroup(Alignment.LEADING)
       				.addComponent(player1Bid, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
       				.addComponent(player1Offer))
       			.addGap(65)
       			.addGroup(layout.createParallelGroup(Alignment.LEADING)
       				.addComponent(player2Bid)
       				.addComponent(player2Offer))
       			.addPreferredGap(ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
       			.addGroup(layout.createParallelGroup(Alignment.LEADING)
       				.addComponent(player4Bid, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
       				.addComponent(player3Offer))
       			.addGap(54)
       			.addGroup(layout.createParallelGroup(Alignment.LEADING)
       				.addComponent(player4Offer)
       				.addComponent(player3Bid))
       			.addPreferredGap(ComponentPlacement.RELATED, 71, Short.MAX_VALUE)
       			.addGroup(layout.createParallelGroup(Alignment.TRAILING)
       				.addComponent(jProgressBar1, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE)
       				.addComponent(storeAuctionLabel))
       			.addContainerGap())
       		.addGroup(layout.createSequentialGroup()
       			.addGap(289)
       			.addComponent(auctionLabel)
       			.addGap(0, 361, Short.MAX_VALUE))
       );
       layout.setVerticalGroup(
       	layout.createParallelGroup(Alignment.TRAILING)
       		.addGroup(layout.createSequentialGroup()
       			.addContainerGap(24, Short.MAX_VALUE)
       			.addComponent(auctionLabel)
       			.addGap(18)
       			.addGroup(layout.createParallelGroup(Alignment.TRAILING)
       				.addGroup(layout.createParallelGroup(Alignment.TRAILING, false)
       					.addComponent(jSeparator1, GroupLayout.PREFERRED_SIZE, 351, GroupLayout.PREFERRED_SIZE)
       					.addGroup(layout.createSequentialGroup()
       						.addGroup(layout.createParallelGroup(Alignment.LEADING)
       							.addGroup(layout.createSequentialGroup()
       								.addGap(42)
       								.addComponent(maxLabel))
       							.addGroup(layout.createSequentialGroup()
       								.addGap(22)
       								.addComponent(sellLabel)))
       						.addPreferredGap(ComponentPlacement.RELATED)
       						.addComponent(maxMoney)
       						.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
       						.addComponent(minLabel)
       						.addPreferredGap(ComponentPlacement.RELATED)
       						.addComponent(minMoney)
       						.addGap(9)
       						.addComponent(buyLabel)
       						.addGap(27)))
       				.addGroup(layout.createSequentialGroup()
       					.addGroup(layout.createParallelGroup(Alignment.BASELINE)
       						.addComponent(player4Bid, GroupLayout.PREFERRED_SIZE, 16, GroupLayout.PREFERRED_SIZE)
       						.addComponent(player1Bid)
       						.addComponent(player3Bid)
       						.addComponent(storeAuctionLabel)
       						.addComponent(player2Bid))
       					.addPreferredGap(ComponentPlacement.RELATED, 58, Short.MAX_VALUE)
       					.addGroup(layout.createParallelGroup(Alignment.TRAILING)
       						.addGroup(layout.createParallelGroup(Alignment.LEADING)
       							.addComponent(player1Offer, Alignment.TRAILING)
       							.addComponent(jProgressBar1, GroupLayout.PREFERRED_SIZE, 297, GroupLayout.PREFERRED_SIZE))
       						.addGroup(layout.createParallelGroup(Alignment.BASELINE)
       							.addComponent(player3Offer)
       							.addComponent(player4Offer))
       						.addComponent(player2Offer))
       					.addPreferredGap(ComponentPlacement.RELATED)))
       			.addGroup(layout.createParallelGroup(Alignment.TRAILING)
       				.addComponent(player1StatusPanel, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE)
       				.addComponent(player2StatusPanel, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE)
       				.addComponent(player4StatusPanel, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE)
       				.addComponent(player3StatusPanel, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE)
       				.addComponent(storeStatusPanel, GroupLayout.PREFERRED_SIZE, 108, GroupLayout.PREFERRED_SIZE)))
       );
       getContentPane().setLayout(layout);

       setSize(new java.awt.Dimension(786, 578));
       setLocationRelativeTo(null);
   }// </editor-fold>                        

   private javax.swing.JLabel player1NameLabel;
   private javax.swing.JLabel player1MoneyLabel;
   private javax.swing.JLabel player1FoodLabel;
   private javax.swing.JLabel player1EnergyLabel;
   private javax.swing.JLabel player1SmithoreLabel;
   private javax.swing.JLabel player1Name;
   private javax.swing.JLabel player1Money;
   private javax.swing.JLabel player1Food;
   private javax.swing.JLabel player1Energy;   
   private javax.swing.JLabel player1Smithore;
   private javax.swing.JLabel player2NameLabel;
   private javax.swing.JLabel player2MoneyLabel;
   private javax.swing.JLabel player2FoodLabel;
   private javax.swing.JLabel player2EnergyLabel;
   private javax.swing.JLabel player2SmithoreLabel;
   private javax.swing.JLabel player2Name;
   private javax.swing.JLabel player2Money;
   private javax.swing.JLabel player2Food;
   private javax.swing.JLabel player2Energy;
   private javax.swing.JLabel player2Smithore;
   private javax.swing.JLabel player3NameLabel;
   private javax.swing.JLabel player3MoneyLabel;
   private javax.swing.JLabel player3FoodLabel;
   private javax.swing.JLabel player3EnergyLabel;
   private javax.swing.JLabel player3SmithoreLabel;
   private javax.swing.JLabel player3Name;
   private javax.swing.JLabel player3Money;
   private javax.swing.JLabel player3Food;
   private javax.swing.JLabel player3Energy;
   private javax.swing.JLabel player3Smithore;
   private javax.swing.JLabel player4NameLabel;
   private javax.swing.JLabel player4MoneyLabel;
   private javax.swing.JLabel player4FoodLabel;
   private javax.swing.JLabel player4EnergyLabel;
   private javax.swing.JLabel player4SmithoreLabel;
   private javax.swing.JLabel player4Name;
   private javax.swing.JLabel player4Money;
   private javax.swing.JLabel player4Food;
   private javax.swing.JLabel player4Energy;
   private javax.swing.JLabel player4Smithore;
   private javax.swing.JLabel storeLabel;
   private javax.swing.JLabel storeFoodLabel;
   private javax.swing.JLabel storeEnergyLabel;
   private javax.swing.JLabel storeSmithoreLabel;
   private javax.swing.JLabel storeMuleLabel;
   private javax.swing.JLabel storeAmount;
   private javax.swing.JLabel storeFood;
   private javax.swing.JLabel storeEnergy;
   private javax.swing.JLabel storeSmithore;
   private javax.swing.JLabel storeMule;
   private javax.swing.JLabel buyLabel;
   private javax.swing.JLabel sellLabel;
   private javax.swing.JLabel minLabel;
   private javax.swing.JLabel maxLabel;
   private javax.swing.JLabel maxMoney;
   private javax.swing.JLabel minMoney;
   private javax.swing.JLabel storeAuctionLabel;
   private javax.swing.JLabel auctionLabel;
   private javax.swing.JLabel player1Bid;
   private javax.swing.JLabel player2Bid;
   private javax.swing.JLabel player3Bid;
   private javax.swing.JLabel player4Bid;
   private static javax.swing.JProgressBar jProgressBar1;
   private javax.swing.JSeparator jSeparator1;
   private javax.swing.JLayeredPane player1StatusPanel;
   private javax.swing.JLayeredPane player2StatusPanel;
   private javax.swing.JLayeredPane player3StatusPanel;
   private javax.swing.JLayeredPane player4StatusPanel;
   private javax.swing.JLayeredPane storeStatusPanel;
   private JLabel player1Offer;
   private JLabel player2Offer;
   private JLabel player3Offer;
   private JLabel player4Offer;

}

